<?php

namespace app\merchant\controller;

use app\common\model\Page as PageModel;
use think\Db;
use think\config;

class Page extends Common
{
	public function rule()
	{
		$merchant = Db::table('merchant')->where('merchant_id', 'eq', session('merchant.merchant_id'))->find();
		$data = Db::table('merchant_popular_rule')->where('delete_time',0)->select();
		foreach ($data as $k => $dataValue) {
			$data[$k]['file_url'] = Config::get('rule_file_path').$dataValue['name'];
		}
		return  view('rule',[
			'merchant' => $merchant,
			'data' => $data
		]);
	}

	public function findChilds()
	{
		$pageCatId = (int)input('param.pageId');

		if(empty($pageCatId))
			return returnJson(0, 'ID参数错误');

		$data['data'] = PageModel::getPages($pageCatId);
		
		return returnJson(1, '', $data);
		// return returnJson(1, '', $data);
	}



	public function getPageContent()
	{
		$id = (int)input('param.id');

		if(empty($id))
			return returnJson(0, 'ID参数错误');

		$data = PageModel::getPageContent($id);
		return returnJson(1, '', $data);
	}  
	public function ruleDetail()
	{
		$catId = input('param.catId');
		if(!$catId)
			return retrurnJson(0, 'ID参数错误');

		$data['pageCategory'] = PageModel::getPages($catId);
		$data['total'] = count($data['pageCategory']);
		return returnJson(1, '', $data);
	}
	
}